package cn.iocoder.yudao.module.book.dal.mysql.books;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
//import cn.iocoder.yudao.module.book.controller.app.bookcase.vo.AppBooksRespVO;
import cn.iocoder.yudao.module.book.controller.app.bookcase.vo.AppBooksRespVO;
import cn.iocoder.yudao.module.book.dal.dataobject.books.BooksDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.book.controller.admin.books.vo.*;
import org.apache.ibatis.annotations.Param;

/**
 * 绘本 Mapper
 *
 * @author xi
 */
@Mapper
public interface BooksMapper extends BaseMapperX<BooksDO> {

    default PageResult<BooksDO> selectPage(BooksPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<BooksDO>()
                .eqIfPresent(BooksDO::getBookId, reqVO.getBookId())
                .eqIfPresent(BooksDO::getCollectionId, reqVO.getCollectionId())
                .eqIfPresent(BooksDO::getTitle, reqVO.getTitle())
                .eqIfPresent(BooksDO::getSort, reqVO.getSort())
                .eqIfPresent(BooksDO::getImage, reqVO.getImage())
                .betweenIfPresent(BooksDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(BooksDO::getBookId));
    }

    List<AppBooksRespVO> selectByCollectionsId(@Param("collectionId") Integer id);
    List<AppBooksRespVO> selectAll(@Param("sort") Integer sort);

    BooksDO getByBookId(@Param("bookId") Integer bookId,@Param("sort") String sort);

    List<AppBooksRespVO> selectLikeContent(String content);

    /**
     * 获取某绘本集下的最大排序值
     */
    Integer selectMaxSortByCollectionId(@Param("collectionId") Integer collectionId);
}